<template>
	<view style="padding-bottom: 20rpx;">
		<u-navbar title="我的接单" :placeholder="true" :autoBack="true">
		</u-navbar>
		<view class="top-box">
			<view class="top-tabs">
				<view :class="item.show == true?'active-item':''" class="tabs-item" v-for="(item,index) in topList"
					:key="index" @click="cutTop(index)">
					{{item.title}}
				</view>
			</view>
		</view>
		<u-tabs :list="list" @click="click" :itemStyle="itemStyle"
			lineColor="linear-gradient( 90deg, #5755F2 0%, #D83EFF 100%)" lineWidth="30"
			:activeStyle="activeStyle"></u-tabs>
		<view class="store" v-show="status == 0">
			<view class="store-item" v-for="(item,index) in MyBuyList" :key="index" @click="goDetails(item.orderid)">
				<view class="store-title">
					<view>
						{{item.subject.title}}
					</view>
					<view>
						{{item.hours}}小时
					</view>
				</view>
				<view class="store-info">
					<view class="info-left">
						<image :src="'https://m.lqvvvv.com'+item.you_avatar" mode=""></image>
						<view class="info-msg">
							<view class="goods">
								名称：{{item.you_nickname}}
							</view>
							<view class="info-text">
								时间：{{$u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM:ss')}}
							</view>
							<view class="info-text">
								单号：{{item.orderid}}
							</view>
							<view class="info-text">
								地点：{{item.address}}
							</view>
						</view>
					</view>
					<view class="store-price">
						￥<text>{{item.pay_money}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="play" v-show="status == 1">
			<view class="play-item" v-for="(item,index) in MyplayList" :key="index" @click="gopwdetails(item.orderid)">
				<view class="play-title">
					<image :src="item.avatar.startsWith('http') ? item.avatar : 'https://m.lqvvvv.com' + item.avatar || 'https://m.lqvvvv.com/assets/static/index/head.png'" mode="aspectFill"></image>
					</image>
					<view>
						{{item.nickname}}
					</view>
				</view>
				<view class="play-info">
					<view class="play-left">
						<view class="name">
							<text v-if="item.order_type == 'sing'">唱歌</text>
							<text v-if="item.order_type == 'voice'">语音</text>
							<text v-if="item.order_type == 'video'">视频</text>
							{{item.hours}}小时
						</view>
						<view class="time" style="margin-top: 20rpx;">
							时间：{{$u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM:ss')}}
						</view>
						<view class="time">
							单号：{{item.orderid}}
						</view>
					</view>
					<view class="play-price">
						￥ <text>{{item.total_money}}</text>
					</view>
				</view>
			</view>
		</view>
		<u-loadmore :status="loadmorestatus" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '全部',
				}, {
					name: '待接单',
				}, {
					name: '待开始'
				}, {
					name: '进行中'
				}, {
					name: '已结束'
				}, {
					name: '已取消'
				}],
				itemStyle: {
					backgroundColor: '#fff',
					width: "20%",
					height: '100rpx',
				},
				activeStyle: {
					fontSize: '32rpx',
					color: '#2D2D2D',
					fontWeight: 'bold'
				},
				topList: [{
						title: '探店订单',
						show: true
					},
					{
						title: '陪玩订单',
						show: false
					}
				],
				page: 1,
				status: 0,
				order_status: 0,
				MyBuyList: [],
				loadmorestatus: 'loadmore',
				MyplayList: []
			}
		},
		onLoad() {
			this.buylist()
		},
		onReachBottom() {
			this.page = this.page + 1
			this.loadmorestatus = 'loading';
			if(this.status == 0){
				this.buylist()
			}else{
				this.peiwanlist()
			}
		},
		methods: {
			gopwdetails(id){
				uni.navigateTo({
					url: '/pages/my/order/details-pw-my?id=' + id 
				})
			},
			peiwanlist() {
				let params = {
					order_status: this.order_status,
					page: this.page,
					limit: 10
				}
				this.$Request({
					method: 'POST',
					url: '/api/play_order/getBuyMeList',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						if (res.data.data.length < 10) {
							this.loadmorestatus = 'nomore';
						}
						if (this.page == 1) {
							this.MyplayList = res.data.data
						} else {
							this.MyplayList = [ ...this.MyplayList,...res.data.data]
						}
					}
				})
			},
			buylist() {
				let params = {
					order_status: this.order_status,
					page: this.page,
					limit: 10
				}
				this.$Request({
					method: 'POST',
					url: '/api/friend_order/getBuyMeList',
					data: params,
					ismsg: false,
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						if (res.data.data.length < 10) {
							this.loadmorestatus = 'nomore';
						}
						if (this.page == 1) {
							this.MyBuyList = res.data.data
						} else {
							this.MyBuyList = [...this.MyBuyList,...res.data.data]
						}
					}
				})
			},
			click(item) {
				console.log(item)
				this.order_status = item.index
				if (this.status == 0) {
					this.page = 1
					this.buylist()
				} else {
					this.page = 1
					this.peiwanlist()
				}
			},
			cutTop(index) {
				this.topList.map(item => {
					item.show = false
				})
				this.topList[index].show = true
				this.status = index
				if (this.status == 0) {
					this.page = 1
					this.buylist()
				} else {
					this.page = 1
					this.peiwanlist()
				}
			},
			goDetails(id) {
				uni.navigateTo({
					url: '/pages/my/order/details-my?id=' + id
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.nav-right {
		background-color: #E4E3FF;
		border-radius: 30rpx;
		padding: 5rpx 15rpx;
		display: flex;
		align-items: center;
		font-size: 24rpx;
		color: #5755F2;
		font-weight: 600;

		image {
			width: 30rpx;
			height: 30rpx;
			border-radius: 50%;
			margin-right: 10rpx;
		}
	}

	.top-box {
		background-color: #ffffff;
		display: flex;
		justify-content: center;
		padding: 20rpx;

		.top-tabs {
			width: 65%;
			display: flex;
			justify-content: space-between;
			padding: 6rpx;
			background-color: #F4F4F4;
			border-radius: 40rpx;

			.tabs-item {
				padding: 20rpx 50rpx;
				border-radius: 40rpx;
				color: #19394A;
				font-size: 28rpx;
				font-weight: bold;
			}

			.active-item {
				background-color: #5755F2;
				color: #fff;
			}
		}
	}

	.store {
		padding: 0 30rpx 30rpx;

		.store-item {
			height: 330rpx;
			background-image: url('https://m.lqvvvv.com/assets/static/my/store-bg.png');
			background-repeat: no-repeat;
			background-size: 100% 330rpx;
			margin-top: 30rpx;
			padding: 20rpx 30rpx;

			.store-title {
				display: flex;
				align-items: center;
				font-size: 28rpx;
				color: #2d2d2d;
				font-weight: bold;
				padding-bottom: 20rpx;
				border-bottom: 1rpx solid #fff;
				justify-content: space-between;

			}

			.store-info {
				display: flex;
				justify-content: space-between;
				margin-top: 30rpx;

				.info-left {
					display: flex;

					image {
						width: 115rpx;
						height: 115rpx;
						border-radius: 50%;
					}

					.info-msg {
						font-size: 24rpx;
						margin-left: 20rpx;

						.goods {
							color: #9E9BA4;
							margin-bottom: 10rpx;

							text {
								margin-right: 15rpx;
								color: #2D2D2D;
								font-size: 28rpx;
								font-weight: bold;
							}
						}

						.info-text {
							width: 300rpx;
							margin-top: 20rpx;
							color: #9E9BA4;
							white-space: nowrap;
							/* 不换行 */
							overflow: hidden;
							/* 隐藏超出的内容 */
							text-overflow: ellipsis;
							/* 用省略号表示被隐藏的部分 */
						}

					}
				}

				.store-price {
					color: #2D2D2D;
					font-size: 24rpx;
					font-weight: bold;

					text {
						font-size: 32rpx;
						color: #F24789;
						margin-left: 10rpx;
					}
				}
			}

		}
	}

	.play {
		padding: 0 30rpx 30rpx;

		.play-item {
			height: 238rpx;
			background-image: url('https://m.lqvvvv.com/assets/static/my/play-bg.png');
			background-repeat: no-repeat;
			background-size: 100% 238rpx;
			margin-top: 30rpx;
			padding: 20rpx 30rpx;

			.play-title {
				display: flex;
				align-items: center;
				font-size: 28rpx;
				color: #2d2d2d;
				font-weight: bold;
				padding-bottom: 30rpx;
				border-bottom: 1rpx solid #fff;

				image {
					width: 30rpx;
					height: 30rpx;
					margin-right: 10rpx;
				}
			}

			.play-info {
				display: flex;
				justify-content: space-between;

				.play-left {
					.name {
						color: #B0B0B0;
						font-size: 24rpx;

						text {
							margin-right: 15rpx;
							color: #2D2D2D;
							font-size: 28rpx;
							font-weight: bold;
						}
					}

					.time {
						color: #9E9BA4;
						font-size: 24rpx;
						margin-top: 10rpx;
					}
				}

				.play-price {
					color: #2D2D2D;
					font-size: 24rpx;
					font-weight: bold;

					text {
						font-size: 32rpx;
						color: #F24789;
						margin-left: 10rpx;
					}
				}
			}

		}
	}
</style>